package com.dianzi.certification.controller;

import com.dianzi.certification.service.CertRejectService;
import com.dianzi.certification.utils.JwtUtils;
import com.dianzi.certification.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author copa
 * @createDate 2022-03-29 16:49
 * @function
 */
@RestController
@Api(tags = {"驳回接口"})
public class CertRejectController {

    @Resource
    private CertRejectService certRejectService;

    @PreAuthorize("hasAnyAuthority('ROLE_PRINCIPAL')")
    @GetMapping("lastReject")
    @ApiOperation(value = "查询最近一次驳回理由")
    public R<String> lastReject(HttpServletRequest request) {
        Integer userId = JwtUtils.getUserId(request.getHeader("Authorization"));
        return certRejectService.lastReject(userId);
    }
}
